package nl.fonfolio.view {
	import flash.display.*;
	import flash.text.TextField;

	import nl.fonfolio.model.Model;
	import nl.fonfolio.controller.Controller;

	import nl.fonfolio.core.FonfolioEvent;	
	
	/**
	 * @author Niels
	 */
	public class Profile extends Sprite {
		private var model:Model;
		private var controller:Controller;
		
		public var fonfolio:Sprite;
		
		public var name_txt:TextField;
		public var city_txt:TextField;
		public var email_txt:TextField;
		public var website_txt:TextField;
		public var city_label:TextField;
		public var email_label:TextField;
		public var website_label:TextField;
		public var skills_label:TextField;

		public function Profile(fonfolio:Sprite,model:Model,controller:Controller) {
			this.fonfolio = fonfolio;
			this.model = model;
			this.controller = controller;
			
			this.model.addEventListener(FonfolioEvent.CONTROL_TYPE, this.update);
		}

		private function update(event : FonfolioEvent) : void {
			switch (event.command){
				case "LOAD_PORTFOLIO":
					var portfolio:Object = this.model.getPortfolio();
					
					this.name_txt.text = portfolio.firstName+" "+portfolio.lastName;
					this.city_txt.text = portfolio.city;
					this.email_txt.text = portfolio.email;
					this.website_txt.text = portfolio.website;
				break;
			}
		}
	}
}
